include(basedef.m4)divert(-1)

define("{undefinedCallback}","{ifelse($#,2,"{$1="$2"}","{$1( XMLDEF?, shift($@))}")}")

define("{_UC}","{translit($1,abcdefghijklimnopqrstuvwxyz,ABCDEFGHIJKLIMNOPQRSTUVWXYZ)}")

define("{_xml}","{ifelse( $#,0,,
			  $#,2,"{$1="$2"}",
			  eval($#>2),1,"{<$1"{}"$0($2)>shift(shift($@))</$1>}",
			  $1,,,"{ $1}")}")
define("{_}","{_xml($@)}")
define("{_tag_def_}","{define_( $1,"{_xml( $1,$}""{@)}")define_(_UC($1),"{_xml( $1,$}""{@)}")}")

   TO Do:  stack these 

define("{_open_tag}","{ifelse(	$#,0,,
				$#,1,<$1>,
				$2,,<$1>,<$1 $2>)}")
define("{_end_tag}","{</$1>}")

define_( allspace,"{translit($1,"{
       }","{  }")}")

define_(first,"{substr($1,0,index(_allspace($1) ,"{ }"))}")

define_(rest,"{substr($1,eval(index(_allspace($1) ,"{ }")+1))}")

define_(addlist,"{ifdef("{_$1_list}",
                       "{define_($1_list,defn("{_$1_list}")"{ $2}")}",
                       "{define_($1_list,"{$2}")}")}")

define_(list,"{ifdef("{_$1_list}","{_$1_list}")}")

define_(foreach_,"{ifelse($1,,,"{_$2(_first($1))$0(_rest($1),$2)}")}")

divert(0)dnl
